#ifndef _RICH_TEXT_PARSER_H
#define _RICH_TEXT_PARSER_H

#include <UIRichText.h>

NS_CC_BEGIN
namespace ui {

	class RichTextParser : public SAXDelegator
	{
	public:
		RichTextParser();
		~RichTextParser();

		void updateRichText(RichText* richtext, const std::string& str);

		virtual void startElement(void *ctx, const char *name, const char **atts);
		virtual void endElement(void *ctx, const char *name);
		virtual void textHandler(void *ctx, const char *s, int len);
	private:
		void parseParagraph(const std::string& _value);
		void parseText(const std::string& _value);
		void parseTag(const std::string& _value);
	private:
		RichText* mRichText;

		int mTagIndex;
		bool mBold;
		bool mItalic;
		bool mStrike;
		bool mUnder;
		bool mImage;
		bool mHeader1;
		bool mHeader2;
		bool mHeader3;
		bool mColour;
		bool mUrl;
		Color3B mColourValue;
		CCSize mImageSize;
		CCSize mSpacer;
		std::string mUrlValue;
		std::string mLinkPoiner;

		std::string mHeader1Font;
		std::string mHeader2Font;
		std::string mHeader3Font;
		std::string mDefaultFont;
		std::string mBoldFont;
		std::string mItalicFont;
		std::string mBoldItalicFont;

		int mBreakHeight;
	};
}

NS_CC_END

#endif //_RICH_TEXT_PARSER_H